package com.pay.game.central.system.service;

import com.github.pagehelper.Page;
import com.pay.game.central.system.bean.Role;
import com.pay.game.central.system.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleService {

    @Autowired
    RoleMapper roleMapper;

    public Page<Role> list( String name){
        return roleMapper.list(name);
    }

    public void addRole(String name, String detail){
        Role role = new Role();
        role.setDetail(detail);
        role.setName(name);
        roleMapper.insertItem(role);
    }

    public Role getRoleByName(String name){
        return roleMapper.findRoleByName(name);
    }

    public void deleteRole(int id){
        roleMapper.deleteOne(id);
        roleMapper.deleteOneFromRoleUserMap(id);
    }

}
